package com.exchange.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.exchange.entity.pojo.PowerStatus;
import com.exchange.entity.vo.ManagerPowerVo;
import com.exchange.service.PowerStatusService;
import com.exchange.mapper.PowerStatusMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Random;

/**
* @author Administrator
* @description 针对表【power_status】的数据库操作Service实现
* @createDate 2024-04-27 19:54:09
*/
@Service
public class PowerStatusServiceImpl extends ServiceImpl<PowerStatusMapper, PowerStatus>
    implements PowerStatusService{
    @Autowired
    private PowerStatusMapper powerStatusMapper;
    @Override
    public List<PowerStatus> powerStatesList(Integer id) {
        return this.powerStatusMapper.powerStatesList(id);
    }

    @Override
    public Page<ManagerPowerVo> managerPowerList(Integer offset, Integer pageSize, Integer mid, Integer id, Integer pid, Integer status) {
        return this.powerStatusMapper.managerPowerList(new Page<>(offset,pageSize),mid,id,pid,status);
    }

    @Override
    public ManagerPowerVo managerPowerFindId(Integer id) {
        return this.powerStatusMapper.managerPowerFindId(id);
    }

    @Override
    public boolean addManagerPower(PowerStatus powerStatus) {
        Random random=new Random();
        random.nextInt(100);
        String pname = "s"+(random.nextInt(1000000000))+(random.nextInt(10));

        return this.powerStatusMapper.addManagerPower(powerStatus.getPid(),pname);
    }

}




